	<?php 
		$ci= &get_instance();
		$tournament_id = intval($_POST['tournament_id']);
		$listEventCategory = $ci->event_category_tournament_entity->getArrayListOfEventCategory($tournament_id);
		$eventCategoryStatus = eventCategoryStatusDataConfig();
		$eventStatus = eventStatusDataConfig();
		$betStatus = betStatusDataConfig();
		$iC = 0;
	?>
	<div class="clrboth"></div>
	<div class="grid10" style="width:800px;">
		<input type="button" value="Add Category" onclick="add_category_event(<?php echo $tournament_id;?>);" />
		&nbsp;&nbsp;&nbsp;
		<input type="button" value="Add Event" onclick="add_event(<?php echo $tournament_id;?>);" />
		&nbsp;&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="open_event_view(<?php echo $tournament_id;?>);">Live/UpComing Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_closed(<?php echo $tournament_id;?>);">Closed Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_cancelled(<?php echo $tournament_id;?>);">Cancelled Events</a>
		&nbsp;&nbsp;
		<a href="javascript:void(0);" onclick="view_event_hidden_category(<?php echo $tournament_id;?>);">Hidden categories</a>
	</div>
	<br/><br/>
	<div class="clrboth"></div>
<table>
<thead>	
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Category</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Event</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Odds</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Bet Enable</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Status</span></div></th>
	<th><div class="grid2"><span class="bold" style="font-weight:bold;">Result</span></div></th>
	<th><div class="grid1"><span class="bold" style="font-weight:bold;">Who<br/>bet</span></div></th>
	<th><div class="grid3"><span class="bold" style="font-weight:bold;">Manage</span></div></th>
</thead>	
<tbody>	
	<div class="clrboth"></div>
	<?php foreach( $listEventCategory as $item ): ?>
		<?php 
			$EVENT_CATEGORY = $ci->event_category_tournament_entity->init('id',$item->id);
			$eventArray = $ci->event_tournament_entity->getArrayListOfEvent($EVENT_CATEGORY->getId());
			$iC++;
			$style= ($iC %2 == 0) ? "":"";
		?>
	 <tr class="cat">
		<td><div class="grid2" <?php echo $style;?>><?php echo $EVENT_CATEGORY->getCategory(); ?></div></td>
		<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
		<td><div class="grid1" <?php echo $style;?>>&nbsp;</div></td>
		<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
		<td><div class="grid2" <?php echo $style;?>><?php echo $eventCategoryStatus[$EVENT_CATEGORY->getStatus()]; ?></div></td>
		<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
		<td><div class="grid1" <?php echo $style;?>>&nbsp;</div></td>
		<td><div class="grid3" <?php echo $style;?>>
			<a href="javascript:void(0);" onclick="event_category_edit(<?php echo $EVENT_CATEGORY->getId();?>)"><?php echo lang('dataman.edit');?></a>
		<!--	&nbsp;|&nbsp;
			<a href="javascript:void(0);" onclick="event_category_cancel(<?php echo $EVENT_CATEGORY->getId();?>)" >Cancel</a>
			-->
		</div></td>
	</tr>	
	
		<div class="clrboth"></div>
		
		<?php foreach($eventArray as $evObj):?>
			<?php 
				$EVENT = $ci->event_tournament_entity->init('id',$evObj->id);
				$won = ($EVENT->getResult() == 'won') ? 'checked="checked"':'';
				$lost = ($EVENT->getResult() == 'lost') ? 'checked="checked"':'';
				$iC++;
				$style= ($iC %2 == 0) ? "":"";
			?>
		 <?php if($EVENT->getStatus() == 'closed'):?>
		 <tr>
			<td><div class="grid2" <?php echo $style;?>>&nbsp;</div></td>
			<td><div class="grid2" <?php echo $style;?>><?php echo $EVENT->getName(); ?></div></td>
			<td><div class="grid1" <?php echo $style;?>><?php echo $EVENT->getOdds(); ?></div></td>
			<td><div class="grid2" <?php echo $style;?>><?php echo $betStatus[$EVENT->getBetEnable()]; ?></div></td>
			<td><div class="grid2" <?php echo $style;?>><?php echo $eventStatus[$EVENT->getStatus()]; ?></div></td>
			<td><div class="grid2" <?php echo $style;?>>
				<?php echo $EVENT->getResult();?> 
			</div></td>
			<td><div class="grid1" <?php echo $style;?>><a href="javascript:void(0);" onclick="who_bet_event(<?php echo $EVENT->getId();?>)">View</a></div></td>
			<td><div class="grid3" <?php echo $style;?>>
				<a href="javascript:void(0);" onclick="event_edit(<?php echo $EVENT->getId();?>,<?php echo $tournament_id;?>)"><?php echo lang('dataman.edit');?></a>
			<!--	&nbsp;|&nbsp;
				<a href="javascript:void(0);" onclick="event_cancel(<?php echo $EVENT->getId();?>)" >Cancel</a>
				&nbsp;|&nbsp;
				<a href="javascript:void(0);" onclick="event_finish(<?php echo $EVENT->getId();?>)" >Finish</a>
				-->
			</div></td>
		</tr>	
		 <?php endif;?>
			<div class="clrboth"></div>
		<?php endforeach;?>
	<?php endforeach; ?>
</tbody>
</table>		

